package io.github.maojian.tree;


/**
 * 二叉排序树
 */
public class BinarySortTree {
    Node root;

    public BinarySortTree() {
        this.root = null;
    }

    public void makeEmpty() {
        root = null;
    }

    public boolean isEmpty() {
        return root == null;
    }

    /**
     * 查找最小值节点
     * @param node
     * @return
     */
    public Node findMin(Node node) {
        if (node == null) {
            return null;
        } else if (node.left == null) {
            return node;
        } else {
            return findMin(node.left);
        }
    }

    /**
     * 查找最大值节点
     * @param node
     * @return
     */
    public Node findMax(Node node) {
        if (node == null) {
            return null;
        }else if (node.right == null){
            return node;
        }else{
            return findMax(node);
        }
    }

    /**
     *
     * @param val
     * @return
     */
    public boolean isContains(int val) {

        return false;
    }

    public Node insert(int val) {
        return null;
    }


}

class Node {
    public int value;
    public Node left;
    public Node right;

    public Node(int value) {
        this.value = value;
    }

    public Node(int value, Node left, Node right) {
        this.value = value;
        this.left = left;
        this.right = right;
    }
}